package com.wang.springframework.test.bean;

import com.wang.springframework.beans.factory.annotation.Autowired;
import com.wang.springframework.beans.factory.annotation.Value;
import com.wang.springframework.stereotype.Component;

import java.util.Random;

/**
 * @author wangjianhua
 * @Description
 * @date 2021/9/4/004 11:21
 **/
@Component("userService")
public class UserService implements IUserService {


    @Value("${token}")
    private String token;

    @Autowired
    private UserDao userDao;


    @Override
    public String queryUserInfo() {
        try {
            Thread.sleep(new Random(1).nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return userDao.queryUserName("10001") + "，" + token;
    }

    @Override
    public String register(String userName) {
        try {
            Thread.sleep(new Random(1).nextInt(100));
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "注册用户：" + userName + " success！";
    }

    @Override
    public String toString() {
        return "UserService#token={"+token+"}";
    }
}
